package com.ha8.netease.views.team.suggestions
{
	import com.ha8.netease.PrivateNotify;
	import com.ha8.netease.models.WeiboProxy;
	import com.ha8.netease.views.utils.DataUtil;
	import com.rogo.mvc.interfaces.INotification;
	import com.rogo.mvc.sub.mediator.Mediator;
	
	public class SuggestionsViewMediator extends Mediator
	{
		public function SuggestionsViewMediator(viewComponent:Object)
		{
			super(NAME, viewComponent);
		}
		
		//--------------------------------------------------------------------------
		//
		//  Constants
		//
		//--------------------------------------------------------------------------
		
		public static const NAME:String = 'suggestionsViewMediator';
		
		//--------------------------------------------------------------------------
		//
		//  Overridden Methods
		//
		//--------------------------------------------------------------------------
		
		override public function onRegister():void
		{
			proxy.getSuggestionsI();
		}
		
		override public function listNotificationInterests():Array{
			return [PrivateNotify.GET_SUGGESTIONS_RESULT,	PrivateNotify.GET_SUGGESTIONS_ERROR, PrivateNotify.GET_SUGGESTIONS_I_RESULT];
		}
		
		override public function notificationHandler(notification:INotification):void{
			switch(notification.name){
				case PrivateNotify.GET_SUGGESTIONS_RESULT:
				case PrivateNotify.GET_SUGGESTIONS_I_RESULT:
					view.dataGroup.dataProvider = DataUtil.ObjToUsers(notification.param["users"]);
					break;
				case PrivateNotify.GET_SUGGESTIONS_ERROR:
					break;
			}
		
		}
		
		//--------------------------------------------------------------------------
		//
		//  Methods
		//
		//--------------------------------------------------------------------------
		public function get view():SuggestionsView{
			return viewComponent as SuggestionsView;
		}
		
		public function get proxy():WeiboProxy
		{
			return facade.retrieveProxy(WeiboProxy.NAME) as WeiboProxy;
		}
	}
}